home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / asm / cmcrc10.zip / CMCRC.ASM < prev    next >
Assembly Source File  |  1994-02-06  |  21KB  |  823 lines

  1. ; CMCRC.ASM  Public Domain by Celso Minnitti, Jr  Feb-06-94
  2. ;
  3. ; Version:  1.0
  4. ;
  5. ; Compile:  TASM /m2 cmcrc
  6. ;        TLINK /t /3 /x cmcrc
  7. ;
  8. ; CMCRC.ASM is a simple program just to demonstrate how to compute the
  9. ; CRC-16 and CRC-32 using the crc16_table and crc32_table that were
  10. ; generated by CRCTABLE.
  11. ;
  12. ; Although I am providing the full assembly source code to compute the CRC-16
  13. ; and CRC-32 and the C source code to create the crc16_table and crc32_table,
  14. ; I belive that if you don't have any background on CRCs you won't be able to
  15. ; fully comprehend this code. If you wish to learn more about CRCs I suggest
  16. ; the following references:
  17. ; ■ "C Programmer's Guide to Serial Communications", Joe Campbell SAMS
  18. ; publishing ISBN 0-672-30286-1.
  19. ; ■ Dr. Dobb's Journal #188, may 1992. There is a CRC-32 article there that
  20. ; will explain how to generate CRC-32 table and how to compute the CRC-32.
  21. ; The full C source is provided.
  22. ;
  23. ; If you have any questions, comments or suggestions regarding CMCRC
  24. ; please send me an email via internet to celsomj@world.std.com or
  25. ; call me at 617-235-4018 or write to:
  26. ;
  27. ; Celso Minnitti Jr
  28. ; 139 Linden St
  29. ; Wellesley, MA 02181
  30. ;
  31. ; I will be glad to answer all questions.
  32.  
  33. _TEXT    segment dword public 'CODE'
  34.     assume cs:_TEXT, ds:_TEXT
  35.     org     100h
  36. .386
  37.  
  38. start:        cld
  39.         call    whatcpu
  40.         cmp    ax,386h
  41.         jae    l0             ;386 or better?
  42.  
  43.         mov    ax,offset makecrc16     ;
  44.         mov    [amakecrc16],ax      ;
  45.         mov    ax,offset makecrc32     ;if cpu < 386 then use
  46.         mov    [amakecrc32],ax      ;16-bit functions
  47.         mov    ax,offset printcrc32     ;
  48.         mov    [aprintcrc32],ax     ;
  49.         mov    ax,offset printbytes     ;
  50.         mov    [aprintbytes],ax     ;
  51.  
  52. l0:        mov    si,offset msg0         ;CMCRC  Public Domain by Celso
  53.         call    prints             ;print string
  54.  
  55.         mov    si,81h             ;address of DOS command line
  56.         mov    di,offset ARGV
  57. l1:        lodsb
  58.         cmp    al,13             ;is CR?
  59.         jz    l2             ;yes, then finish
  60.         cmp    al,20h             ;skip spaces
  61.         je    l1
  62.         stosb                 ;copy cmd line to ARGV
  63.         jmp    l1
  64.  
  65. l2:        mov    byte ptr [di],0      ;put a NULL at end
  66.         cmp    di,offset ARGV         ;if empty then print Usage:
  67.         jnz    l3             ;else continue
  68.         mov    si,offset msg1         ;Usage: cmcrc <filename.ext>
  69.         jmp    exit
  70.  
  71. l3:        mov    ah,4eh             ;find first
  72.         mov    cx,6             ;system and hidden files
  73.         mov    dx,offset ARGV
  74.         int    21h
  75.         jnc    l4             ;if CF=0 then no errors
  76.         mov    si,offset msg_err0     ;File not found
  77.         jmp    exit
  78.  
  79. l4:        mov    si,offset msg2         ;Filename  Bytes  CRC-32
  80.         call    prints
  81.         call    whatcpu          ;
  82.         xor    bx,bx             ;
  83.         mov    bl,ah             ;print cpu type
  84.         shl    bx,1             ;
  85.         mov    si,[bx+cputype]      ;
  86.         call    prints             ;
  87.  
  88.         mov    si,offset msg3
  89.         call    prints
  90.  
  91. next_file:      mov     ax,3d00h                 ;open file for read
  92.         mov    dx,9eh             ;dos return filename.ext,0
  93.         int    21h             ;at DTA+1EH (80H+1EH) = 9Eh
  94.         jnc    l5
  95.         mov    si,offset msg_err1     ;Unable to open file
  96.         jmp    exit
  97.  
  98. l5:        mov    bx,ax             ;get handle
  99.         mov    [attr],14         ;set attribute to yellow
  100.         mov    al,0
  101.         mov    cx,13
  102.         mov    di,9eh             ;dta+1eh = filename.exe
  103.         repnz    scasb             ;look for a NULL
  104.         mov    al,' '                   ;if filename.ext if less
  105.         dec    di             ;than 13 characters long
  106.         rep    stosb             ;then append spaces
  107.         mov    al,0
  108.         stosb
  109.  
  110.         mov    si,9eh
  111.         call    prints             ;print filename
  112.  
  113.         mov    [attr],10         ;light green
  114.         call    [aprintbytes]         ;print bytes
  115.                 mov     cl,2
  116.         call    printspc         ;print 2 spaces
  117.  
  118. read_ag:        mov     ah,3fh                   ;read
  119.         mov    cx,512*120         ;512*120 (120 sectors)
  120.         mov    dx,offset BUFFER
  121.         int    21h
  122.         jnc    l6
  123.         mov    si,offset msg_err2     ;Error reading file
  124.         jmp    exit
  125.  
  126. l6:        mov    si,dx
  127.         mov    cx,ax
  128.         call    [amakecrc16]
  129.                 call    [amakecrc32]
  130.  
  131.         cmp    cx,512*120
  132.         je    read_ag          ;read next part of file
  133.  
  134.         mov    ah,3eh             ;close file
  135.         int    21h
  136.  
  137.         mov    [attr],11         ;light blue
  138.         call    [aprintcrc32]         ;print CRC-32
  139.  
  140.         mov    cl,2
  141.         call    printspc
  142.         mov    [attr],12         ;light red
  143.         mov    ax,[init_crc16]
  144.         call    print6h          ;print CRC-16
  145.  
  146.         mov    si,offset crlf         ;print CR and LF
  147.         call    prints
  148.  
  149.         mov    [init_crc16],0
  150.         mov    word ptr [init_crc32],0ffffh
  151.         mov    word ptr [init_crc32+2],0ffffh
  152.  
  153.         mov    ah,4fh             ;find next
  154.         int    21h
  155.         jnc    next_file         ;read next file
  156.         jmp    exit1             ;done
  157.  
  158. exit:           call    prints
  159. exit1:        mov    si,offset msg_end     ;restore cursor color to
  160.         call    prints             ;gray (color=7)
  161.         int    20h             ;exit to DOS
  162.  
  163.  
  164. emakecrc16:    mov    dx,[init_crc16]
  165.         call    ecrc16
  166.         mov    [init_crc16],dx
  167.         ret
  168.  
  169. makecrc16:    mov    dx,[init_crc16]
  170.         call    crc16
  171.         mov    [init_crc16],dx
  172.         ret
  173.  
  174. eprintcrc32:    mov    eax,[init_crc32]
  175.                 not     eax                      ;reverse all bits
  176.         call    eprint2h         ;print CRC-32
  177.         ret
  178.  
  179. printcrc32:    mov    ax,word ptr [init_crc32]
  180.         mov    dx,word ptr [init_crc32+2]
  181.         not    ax
  182.         not    dx
  183.         call    print2h
  184.         ret
  185.  
  186. emakecrc32:    mov    edx,[init_crc32]
  187.         call    ecrc32
  188.         mov    [init_crc32],edx
  189.         ret
  190.  
  191. makecrc32:    mov    ax,word ptr [init_crc32]
  192.         mov    dx,word ptr [init_crc32+2]
  193.         call    crc32
  194.         mov    word ptr [init_crc32],ax
  195.         mov    word ptr [init_crc32+2],dx
  196.         ret
  197.  
  198. eprintbytes:    mov    eax,dword ptr ds:[9ah]
  199.         call    eprint2d
  200.         ret
  201.  
  202. printbytes:     mov     ax,word ptr ds:[9ah]
  203.         mov    dx,word ptr ds:[9ch]
  204.         call    print2d
  205.         ret
  206.  
  207. ;**************************************************************************
  208. ; ecrc16 - compute CRC-16 of a given buffer using crc16_table
  209. ;
  210. ; enter:   DS:SI = address of buffer
  211. ;       CX     = length of buffer
  212. ;       DX     = initial CRC value
  213. ;
  214. ; return:  DX     = CRC-16
  215. ;**************************************************************************
  216. ecrc16        proc    near
  217.         push    cx
  218.         push    si
  219.  
  220. ecrc16_loop:    xor    eax,eax
  221.         mov    al,[si]          ;faster than lodsb
  222.         inc    si             ;
  223.         xor    al,dl
  224.         mov    ax,[eax*2+crc16_table]
  225.         xor    al,dh
  226.         mov    dx,ax
  227.         dec    cx             ;faster than loop
  228.         jnz    ecrc16_loop         ;
  229.  
  230.         pop    si
  231.         pop    cx
  232.         ret
  233. ecrc16        endp
  234.  
  235. ;**************************************************************************
  236. ; crc16 - compute CRC-16 of a given buffer using crc16_table
  237. ;
  238. ; enter:   DS:SI = address of buffer
  239. ;       CX     = length of buffer
  240. ;       DX     = initial CRC value
  241. ;
  242. ; return:  DX     = CRC-16
  243. ;**************************************************************************
  244. crc16        proc    near
  245.         push    cx
  246.         push    bx
  247.         push    si
  248.  
  249. crc16_loop:    xor    ax,ax
  250.         mov    al,[si]          ;faster than lodsb
  251.         inc    si             ;
  252.         xor    al,dl
  253.                 shl     ax,1
  254.                 mov     bx,ax
  255.         mov    ax,[bx+crc16_table]
  256.         xor    al,dh
  257.         mov    dx,ax
  258.         dec    cx             ;faster than loop
  259.         jnz    crc16_loop         ;
  260.  
  261.         pop    si
  262.         pop    bx
  263.         pop    cx
  264.         ret
  265. crc16        endp
  266.  
  267. ;**************************************************************************
  268. ; ecrc32 - compute CRC-32 of a given buffer using crc32_table
  269. ;
  270. ; enter:   DS:SI = address of buffer
  271. ;       CX     = length of buffer
  272. ;       EDX     = initial CRC-32 value
  273. ;
  274. ; return:  EDX     = CRC-32
  275. ;**************************************************************************
  276. ecrc32        proc    near
  277.         push    eax
  278.         push    cx
  279.         push    si
  280.  
  281. ecrc32_loop:    xor    eax,eax
  282.         mov    al,[si]          ;faster than lodsb
  283.         inc    si             ;
  284.         xor    al,dl
  285.         mov    eax,[eax*4+crc32_table]
  286.         shr    edx,8
  287.         xor    edx,eax
  288.         dec    cx             ;faster than loop
  289.         jnz    ecrc32_loop         ;
  290.  
  291.         pop    si
  292.         pop    cx
  293.         pop    eax
  294.         ret
  295. ecrc32        endp
  296.  
  297. ;**************************************************************************
  298. ; crc32 - compute CRC-32 of a given buffer using crc32_table
  299. ;
  300. ; enter:   DS:SI = address of buffer
  301. ;       CX     = length of buffer
  302. ;       DX:AX = initial CRC-32 value
  303. ;
  304. ; return:  DX:AX = CRC-32
  305. ;**************************************************************************
  306. crc32        proc    near
  307.         push    cx
  308.         push    bx
  309.         push    si
  310.         push    di
  311.  
  312.         mov    di,cx
  313. crc32_loop:    xor    bx,bx
  314.         mov    bl,[si]
  315.         inc    si
  316.         xor    bl,al
  317.         shl    bx,1
  318.                 shl     bx,1
  319.         mov    cx,word ptr [bx+crc32_table]
  320.         mov    al,ah
  321.         mov    ah,dl
  322.         xor    ax,cx
  323.         mov    cx,word ptr [bx+2+crc32_table]
  324.         mov    dl,dh
  325.         mov    dh,0
  326.         xor    dx,cx
  327.         dec    di
  328.         jnz    crc32_loop
  329.  
  330.         pop    di
  331.         pop    si
  332.         pop    bx
  333.         pop    cx
  334.         ret
  335. crc32        endp
  336.  
  337. ;**************************************************************************
  338. ;                   EPRINT2H
  339. ; enter:   EAX = # to print in hexadecimal
  340. ;**************************************************************************
  341. eprint2h    proc    near
  342.         push    eax
  343.         push    cx
  344.         push    edx
  345.         push    di
  346.  
  347.         mov    cx,8
  348.         mov    edx,eax
  349. epri21:     rol    edx,4
  350.         mov    al,dl
  351.         and    al,0fh
  352.         daa
  353.         add    al,0f0h
  354.         adc    al,40h
  355.         call    putchar
  356.         dec    cx
  357.         jnz    epri21
  358.  
  359.         pop    di
  360.         pop    edx
  361.         pop    cx
  362.         pop    eax
  363.         ret
  364. eprint2h    endp
  365.  
  366. ;**************************************************************************
  367. ;                   PRINT2H
  368. ; enter:   DX:AX = # to print in hexadecimal
  369. ;**************************************************************************
  370. print2h     proc    near
  371.         push    ax
  372.         push    cx
  373.         push    dx
  374.         push    si
  375.         push    di
  376.  
  377.         push    ax
  378.         mov    cx,4
  379.         mov    si,cx
  380. pri21:        rol    dx,cl
  381.         mov    al,dl
  382.         and    al,0fh
  383.         daa
  384.         add    al,0f0h
  385.         adc    al,40h
  386.         call    putchar
  387.         dec    si
  388.         jnz    pri21
  389.  
  390.         pop    dx
  391.         mov    si,4
  392. pri22:        rol    dx,cl
  393.         mov    al,dl
  394.         and    al,0fh
  395.         daa
  396.         add    al,0f0h
  397.         adc    al,40h
  398.         call    putchar
  399.         dec    si
  400.         jnz    pri22
  401.  
  402.         pop    di
  403.         pop    si
  404.         pop    dx
  405.         pop    cx
  406.         pop    ax
  407.         ret
  408. print2h     endp
  409.  
  410. ;**************************************************************************
  411. ;                PRINT6H
  412. ; enter:   AX = # to print in hexadecimal
  413. ;**************************************************************************
  414. print6h     proc    near
  415.         push    ax
  416.         push    cx
  417.         push    dx
  418.         push    di
  419.  
  420. pri61:        mov    cx,4
  421.         mov    dx,ax
  422. pri62:        rol    dx,4
  423.         mov    al,dl
  424.         and    al,0fh
  425.         daa
  426.         add    al,0f0h
  427.         adc    al,40h
  428.         call    putchar
  429.         dec    cx
  430.         jnz    pri62
  431.  
  432.         pop    di
  433.         pop    dx
  434.         pop    cx
  435.         pop    ax
  436.         ret
  437. print6h     endp
  438.  
  439. ;**************************************************************************
  440. ;                   EPRINT2D
  441. ; enter:   EAX = # to print in decimal
  442. ;**************************************************************************
  443. eprint2d    proc    near
  444.         push    eax
  445.                 push    cx
  446.                 push    edx
  447.         push    ebx
  448.         push    si
  449.         push    di
  450.  
  451.         xor    cx,cx
  452.         mov    si,offset pbuff
  453.         mov    ebx,10
  454.  
  455. epri21d:    xor    edx,edx
  456.         div    ebx
  457.         add    dl,30h
  458.         mov    [si],dl
  459.         inc    si
  460.         inc    cx
  461.         or    eax,eax
  462.         jnz    epri21d
  463.  
  464. epri22d:    mov    ah,cl
  465.         mov    cl,10
  466.         sub    cl,ah
  467.         push    si
  468.         call    printspc
  469.         pop    si
  470.         mov    cl,ah
  471.  
  472. epri23d:    dec    si
  473.         mov    al,[si]
  474.         call    putchar
  475.         dec    cx
  476.         jnz    epri23d
  477.  
  478.         pop    di
  479.         pop    si
  480.         pop    ebx
  481.         pop    edx
  482.         pop    cx
  483.         pop    eax
  484.         ret
  485. eprint2d    endp
  486.  
  487.  
  488. ;**************************************************************************
  489. ;                PRINT2D
  490. ; enter:   DX:AX = # to print in decimal
  491. ;**************************************************************************
  492. print2d     proc    near
  493.         push    ax
  494.         push    cx
  495.         push    dx
  496.         push    bx
  497.         push    si
  498.         push    di
  499.  
  500.         xor    cx,cx
  501.         mov    bx,10
  502.                 mov     si,offset pbuff
  503.                 mov     di,dx
  504.  
  505. pri21d:     inc    cx
  506.         xchg    di,ax
  507.         xor    dx,dx
  508.         div    bx
  509.         xchg    di,ax
  510.         div    bx
  511.         add    dl,30h
  512.         mov    [si],dl
  513.         inc    si
  514.         or    di,di
  515.         jnz    pri21d
  516.  
  517. pri22d:     or    ax,ax
  518.         jz    pri23d
  519.         inc    cx
  520.         xor    dx,dx
  521.         div    bx
  522.         add    dl,30h
  523.         mov    [si],dl
  524.         inc    si
  525.         jmp    pri22d
  526.  
  527. pri23d:     mov    ah,cl
  528.         mov    cl,10
  529.         sub    cl,ah
  530.         call    printspc
  531.         mov    cl,ah
  532.  
  533. pri24d:     dec    si
  534.                 mov     al,[si]
  535.         call    putchar
  536.                 dec     cx
  537.         jnz    pri24d
  538.  
  539.         pop    di
  540.         pop    si
  541.         pop    bx
  542.         pop    dx
  543.         pop    cx
  544.         pop    ax
  545.         ret
  546. print2d     endp
  547.  
  548.  
  549. ;**************************************************************************
  550. ;                 PUTCHAR
  551. ; enter:   AL = character to send to STDOUT
  552. ;**************************************************************************
  553. putchar         proc    near
  554.         push    ax
  555.         push    cx
  556.         push    dx
  557.         push    bx
  558.         mov    dl,al             ;get character
  559.  
  560.         cmp    al,13             ;CR
  561.         je    putchar1
  562.         cmp    al,10             ;LF
  563.         je    putchar1
  564.  
  565.         mov    al,' '                   ;print a space
  566.         mov    ah,9             ;write a character and
  567.                          ;attribute at cursor positon
  568.         mov    cx,1             ;# of times
  569.         mov    bh,0             ;page number
  570.         mov    bl,[attr]         ;color of attribute
  571.         int    10h
  572.  
  573. putchar1:    mov    ah,2             ;write a character to STDOUT
  574.         int    21h
  575.         pop    bx
  576.         pop    dx
  577.         pop    cx
  578.         pop    ax
  579.         ret
  580. putchar         endp
  581.  
  582.  
  583. ;**************************************************************************
  584. ;                 WHATCPU
  585. ; return:  AX = 0088h for 8088 cpu
  586. ;       AX = 0286h for 80286 cpu
  587. ;       AX = 0386h for 80386 cpu
  588. ;       AX = 0486h for 80486 cpu
  589. ;**************************************************************************
  590. whatcpu     proc    near
  591.         pushf
  592.  
  593.         xor    ax,ax
  594.         push    ax
  595.         popf
  596.         pushf
  597.         pop    ax
  598.         and    ax,0f000h
  599.         cmp    ax,0f000h
  600.         je    is_8088
  601.  
  602.         or    ax,0f000h
  603.         push    ax
  604.         popf
  605.         pushf
  606.         pop    ax
  607.         and    ax,0f000h
  608.         jz    is_80286
  609.  
  610.         pushfd
  611.         pop    eax
  612.         or    eax,40000h
  613.         push    eax
  614.         popfd
  615.         pushfd
  616.         pop    eax
  617.         and    eax,40000h
  618.         jz    is_80386
  619.  
  620. is_80486:    mov    ax,486h
  621.         jmp    whatcpu_ret
  622. is_80386:    mov    ax,386h
  623.         jmp    whatcpu_ret
  624. is_80286:       mov     ax,286h
  625.         jmp    whatcpu_ret
  626. is_8088:    mov    ax,88h
  627. whatcpu_ret:    popf
  628.         ret
  629. whatcpu         endp
  630.  
  631. ;--------------------------------------------------------------------------
  632. ;                 PRINTS
  633. ; enter:   DS:SI = address of string
  634. ;--------------------------------------------------------------------------
  635. prints:     lodsb                 ;load character
  636.         test    al,al             ;is a NULL
  637.         je    prints_ret         ;Yes, return
  638.         cmp    al,1             ;change attr
  639.         jne    prints1
  640.         lodsb                 ;next char is attr color
  641.         mov    [attr],al
  642.         jmp    prints
  643. prints1:    call    putchar
  644.         jmp    prints
  645. prints_ret:    ret
  646.  
  647.  
  648. ;--------------------------------------------------------------------------
  649. ;                   PRINTSPC
  650. ; enter:   CL = # of spaces to print
  651. ;--------------------------------------------------------------------------
  652. printspc:    mov    ch,0
  653.         mov    al,' '
  654. printspc1:    call    putchar
  655.         loop    printspc1
  656.         ret
  657.  
  658. align 4
  659. ; These tables were created by CRCTABLE.C
  660. crc16_table    label    word
  661.     dw 00000h, 0C0C1h, 0C181h, 00140h, 0C301h, 003C0h, 00280h, 0C241h
  662.     dw 0C601h, 006C0h, 00780h, 0C741h, 00500h, 0C5C1h, 0C481h, 00440h
  663.     dw 0CC01h, 00CC0h, 00D80h, 0CD41h, 00F00h, 0CFC1h, 0CE81h, 00E40h
  664.     dw 00A00h, 0CAC1h, 0CB81h, 00B40h, 0C901h, 009C0h, 00880h, 0C841h
  665. ; 20h
  666.     dw 0D801h, 018C0h, 01980h, 0D941h, 01B00h, 0DBC1h, 0DA81h, 01A40h
  667.     dw 01E00h, 0DEC1h, 0DF81h, 01F40h, 0DD01h, 01DC0h, 01C80h, 0DC41h
  668.     dw 01400h, 0D4C1h, 0D581h, 01540h, 0D701h, 017C0h, 01680h, 0D641h
  669.     dw 0D201h, 012C0h, 01380h, 0D341h, 01100h, 0D1C1h, 0D081h, 01040h
  670. ; 40h
  671.     dw 0F001h, 030C0h, 03180h, 0F141h, 03300h, 0F3C1h, 0F281h, 03240h
  672.     dw 03600h, 0F6C1h, 0F781h, 03740h, 0F501h, 035C0h, 03480h, 0F441h
  673.     dw 03C00h, 0FCC1h, 0FD81h, 03D40h, 0FF01h, 03FC0h, 03E80h, 0FE41h
  674.     dw 0FA01h, 03AC0h, 03B80h, 0FB41h, 03900h, 0F9C1h, 0F881h, 03840h
  675. ; 60h
  676.     dw 02800h, 0E8C1h, 0E981h, 02940h, 0EB01h, 02BC0h, 02A80h, 0EA41h
  677.     dw 0EE01h, 02EC0h, 02F80h, 0EF41h, 02D00h, 0EDC1h, 0EC81h, 02C40h
  678.     dw 0E401h, 024C0h, 02580h, 0E541h, 02700h, 0E7C1h, 0E681h, 02640h
  679.     dw 02200h, 0E2C1h, 0E381h, 02340h, 0E101h, 021C0h, 02080h, 0E041h
  680. ; 80h
  681.     dw 0A001h, 060C0h, 06180h, 0A141h, 06300h, 0A3C1h, 0A281h, 06240h
  682.     dw 06600h, 0A6C1h, 0A781h, 06740h, 0A501h, 065C0h, 06480h, 0A441h
  683.     dw 06C00h, 0ACC1h, 0AD81h, 06D40h, 0AF01h, 06FC0h, 06E80h, 0AE41h
  684.     dw 0AA01h, 06AC0h, 06B80h, 0AB41h, 06900h, 0A9C1h, 0A881h, 06840h
  685. ; A0h
  686.     dw 07800h, 0B8C1h, 0B981h, 07940h, 0BB01h, 07BC0h, 07A80h, 0BA41h
  687.     dw 0BE01h, 07EC0h, 07F80h, 0BF41h, 07D00h, 0BDC1h, 0BC81h, 07C40h
  688.     dw 0B401h, 074C0h, 07580h, 0B541h, 07700h, 0B7C1h, 0B681h, 07640h
  689.     dw 07200h, 0B2C1h, 0B381h, 07340h, 0B101h, 071C0h, 07080h, 0B041h
  690. ; C0h
  691.     dw 05000h, 090C1h, 09181h, 05140h, 09301h, 053C0h, 05280h, 09241h
  692.     dw 09601h, 056C0h, 05780h, 09741h, 05500h, 095C1h, 09481h, 05440h
  693.     dw 09C01h, 05CC0h, 05D80h, 09D41h, 05F00h, 09FC1h, 09E81h, 05E40h
  694.     dw 05A00h, 09AC1h, 09B81h, 05B40h, 09901h, 059C0h, 05880h, 09841h
  695. ; E0h
  696.     dw 08801h, 048C0h, 04980h, 08941h, 04B00h, 08BC1h, 08A81h, 04A40h
  697.     dw 04E00h, 08EC1h, 08F81h, 04F40h, 08D01h, 04DC0h, 04C80h, 08C41h
  698.     dw 04400h, 084C1h, 08581h, 04540h, 08701h, 047C0h, 04680h, 08641h
  699.     dw 08201h, 042C0h, 04380h, 08341h, 04100h, 081C1h, 08081h, 04040h
  700.  
  701. crc32_table    label    dword
  702.     dd 000000000h, 077073096h, 0EE0E612Ch, 0990951BAh
  703.     dd 0076DC419h, 0706AF48Fh, 0E963A535h, 09E6495A3h
  704.     dd 00EDB8832h, 079DCB8A4h, 0E0D5E91Eh, 097D2D988h
  705.     dd 009B64C2Bh, 07EB17CBDh, 0E7B82D07h, 090BF1D91h
  706. ; 10h
  707.     dd 01DB71064h, 06AB020F2h, 0F3B97148h, 084BE41DEh
  708.     dd 01ADAD47Dh, 06DDDE4EBh, 0F4D4B551h, 083D385C7h
  709.     dd 0136C9856h, 0646BA8C0h, 0FD62F97Ah, 08A65C9ECh
  710.     dd 014015C4Fh, 063066CD9h, 0FA0F3D63h, 08D080DF5h
  711. ; 20h
  712.     dd 03B6E20C8h, 04C69105Eh, 0D56041E4h, 0A2677172h
  713.     dd 03C03E4D1h, 04B04D447h, 0D20D85FDh, 0A50AB56Bh
  714.     dd 035B5A8FAh, 042B2986Ch, 0DBBBC9D6h, 0ACBCF940h
  715.     dd 032D86CE3h, 045DF5C75h, 0DCD60DCFh, 0ABD13D59h
  716. ; 30h
  717.     dd 026D930ACh, 051DE003Ah, 0C8D75180h, 0BFD06116h
  718.     dd 021B4F4B5h, 056B3C423h, 0CFBA9599h, 0B8BDA50Fh
  719.     dd 02802B89Eh, 05F058808h, 0C60CD9B2h, 0B10BE924h
  720.     dd 02F6F7C87h, 058684C11h, 0C1611DABh, 0B6662D3Dh
  721. ; 40h
  722.     dd 076DC4190h, 001DB7106h, 098D220BCh, 0EFD5102Ah
  723.     dd 071B18589h, 006B6B51Fh, 09FBFE4A5h, 0E8B8D433h
  724.     dd 07807C9A2h, 00F00F934h, 09609A88Eh, 0E10E9818h
  725.     dd 07F6A0DBBh, 0086D3D2Dh, 091646C97h, 0E6635C01h
  726. ; 50h
  727.     dd 06B6B51F4h, 01C6C6162h, 0856530D8h, 0F262004Eh
  728.     dd 06C0695EDh, 01B01A57Bh, 08208F4C1h, 0F50FC457h
  729.     dd 065B0D9C6h, 012B7E950h, 08BBEB8EAh, 0FCB9887Ch
  730.     dd 062DD1DDFh, 015DA2D49h, 08CD37CF3h, 0FBD44C65h
  731. ; 60h
  732.     dd 04DB26158h, 03AB551CEh, 0A3BC0074h, 0D4BB30E2h
  733.     dd 04ADFA541h, 03DD895D7h, 0A4D1C46Dh, 0D3D6F4FBh
  734.     dd 04369E96Ah, 0346ED9FCh, 0AD678846h, 0DA60B8D0h
  735.     dd 044042D73h, 033031DE5h, 0AA0A4C5Fh, 0DD0D7CC9h
  736. ; 70h
  737.     dd 05005713Ch, 0270241AAh, 0BE0B1010h, 0C90C2086h
  738.     dd 05768B525h, 0206F85B3h, 0B966D409h, 0CE61E49Fh
  739.     dd 05EDEF90Eh, 029D9C998h, 0B0D09822h, 0C7D7A8B4h
  740.     dd 059B33D17h, 02EB40D81h, 0B7BD5C3Bh, 0C0BA6CADh
  741. ; 80h
  742.     dd 0EDB88320h, 09ABFB3B6h, 003B6E20Ch, 074B1D29Ah
  743.     dd 0EAD54739h, 09DD277AFh, 004DB2615h, 073DC1683h
  744.     dd 0E3630B12h, 094643B84h, 00D6D6A3Eh, 07A6A5AA8h
  745.     dd 0E40ECF0Bh, 09309FF9Dh, 00A00AE27h, 07D079EB1h
  746. ; 90h
  747.     dd 0F00F9344h, 08708A3D2h, 01E01F268h, 06906C2FEh
  748.     dd 0F762575Dh, 0806567CBh, 0196C3671h, 06E6B06E7h
  749.     dd 0FED41B76h, 089D32BE0h, 010DA7A5Ah, 067DD4ACCh
  750.     dd 0F9B9DF6Fh, 08EBEEFF9h, 017B7BE43h, 060B08ED5h
  751. ; A0h
  752.     dd 0D6D6A3E8h, 0A1D1937Eh, 038D8C2C4h, 04FDFF252h
  753.     dd 0D1BB67F1h, 0A6BC5767h, 03FB506DDh, 048B2364Bh
  754.     dd 0D80D2BDAh, 0AF0A1B4Ch, 036034AF6h, 041047A60h
  755.     dd 0DF60EFC3h, 0A867DF55h, 0316E8EEFh, 04669BE79h
  756. ; B0h
  757.     dd 0CB61B38Ch, 0BC66831Ah, 0256FD2A0h, 05268E236h
  758.     dd 0CC0C7795h, 0BB0B4703h, 0220216B9h, 05505262Fh
  759.     dd 0C5BA3BBEh, 0B2BD0B28h, 02BB45A92h, 05CB36A04h
  760.     dd 0C2D7FFA7h, 0B5D0CF31h, 02CD99E8Bh, 05BDEAE1Dh
  761. ; C0h
  762.     dd 09B64C2B0h, 0EC63F226h, 0756AA39Ch, 0026D930Ah
  763.     dd 09C0906A9h, 0EB0E363Fh, 072076785h, 005005713h
  764.     dd 095BF4A82h, 0E2B87A14h, 07BB12BAEh, 00CB61B38h
  765.     dd 092D28E9Bh, 0E5D5BE0Dh, 07CDCEFB7h, 00BDBDF21h
  766. ; D0h
  767.     dd 086D3D2D4h, 0F1D4E242h, 068DDB3F8h, 01FDA836Eh
  768.     dd 081BE16CDh, 0F6B9265Bh, 06FB077E1h, 018B74777h
  769.     dd 088085AE6h, 0FF0F6A70h, 066063BCAh, 011010B5Ch
  770.     dd 08F659EFFh, 0F862AE69h, 0616BFFD3h, 0166CCF45h
  771. ; E0h
  772.     dd 0A00AE278h, 0D70DD2EEh, 04E048354h, 03903B3C2h
  773.     dd 0A7672661h, 0D06016F7h, 04969474Dh, 03E6E77DBh
  774.     dd 0AED16A4Ah, 0D9D65ADCh, 040DF0B66h, 037D83BF0h
  775.     dd 0A9BCAE53h, 0DEBB9EC5h, 047B2CF7Fh, 030B5FFE9h
  776. ; F0h
  777.     dd 0BDBDF21Ch, 0CABAC28Ah, 053B39330h, 024B4A3A6h
  778.     dd 0BAD03605h, 0CDD70693h, 054DE5729h, 023D967BFh
  779.     dd 0B3667A2Eh, 0C4614AB8h, 05D681B02h, 02A6F2B94h
  780.     dd 0B40BBE37h, 0C30C8EA1h, 05A05DF1Bh, 02D02EF8Dh
  781.  
  782. msg0        db    1,15,'CMCRC 1.0  Public Domain by Celso'
  783.         db    ' Minnitti, Jr  Feb-06-1994',13,10,0
  784. msg1        db    13,10,'Usage:    CMCRC <filename.ext> (* and ? are OK)'
  785.         db    13,10,0
  786. msg2        db    1,14,'Filename       ',1,10,'Bytes    '
  787.         db    1,11,'CRC-32    ',1,12,'CRC-16  ',1,13,'(CPU ',0
  788. msg3        db    13,10,1,14,'─────────────  ',1,10,'───────  '
  789.         db    1,11,'────────  '
  790.         db    1,12,'──────',13,10,0
  791. msg_end     db    1,7,32,0
  792.  
  793. msg_err0    db    'File not found',13,10,0
  794. msg_err1    db    'Unable to open file',13,10,0
  795. msg_err2    db    'Error reading file',13,10,0
  796. cpu8088     db    '8088)',0
  797. cpu80286    db    '80286)',0
  798. cpu80386    db    '80386)',0
  799. cpu80486    db    '80486)',0
  800. crlf            db      13,10,0
  801. attr        db    15
  802.  
  803. init_crc16    dw    0
  804. init_crc32    dd    -1
  805.  
  806. amakecrc16      dw      offset emakecrc16
  807. amakecrc32    dw    offset emakecrc32
  808. aprintcrc32    dw    offset eprintcrc32
  809. aprintbytes    dw    offset eprintbytes
  810.  
  811. cputype     dw    offset cpu8088
  812.         dw    offset cpu8088
  813.         dw    offset cpu80286
  814.         dw    offset cpu80386
  815.         dw    offset cpu80486
  816.  
  817. ARGV        equ    $
  818. PBUFF        equ    $+20
  819. BUFFER        equ    $+30
  820.  
  821. _TEXT    ends
  822. end    start
  823.